package chen.huai.jie.spring.xmlconfig.mybatis;


import org.apache.ibatis.binding.MapperRegistry;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Component;

@Component
public class AutoConfiguration extends Configuration {
    private final AutoMapperRegistry mapperRegistry = new AutoMapperRegistry(this);

    public AutoConfiguration() {
    }

    public MapperRegistry getMapperRegistry() {
        return this.mapperRegistry;
    }

    public void addMappers(String packageName, Class<?> superType) {
        this.mapperRegistry.addMappers(packageName, superType);
    }

    public void addMappers(String packageName) {
        this.mapperRegistry.addMappers(packageName);
    }

    public <T> void addMapper(Class<T> type) {
        this.mapperRegistry.addMapper(type);
    }

    public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
        return this.mapperRegistry.getMapper(type, sqlSession);
    }

    public boolean hasMapper(Class<?> type) {
        return this.mapperRegistry.hasMapper(type);
    }
}
